﻿@page "/scheduler/different-work-days"

@using Syncfusion.Blazor.Schedule
@inherits SampleBaseComponent;

<SampleDescription>
    <p> This demo showcases the different available dates of doctors and their appointments on those days.</p>
</SampleDescription>
<ActionDescription>
    <p>
        In this demo, different working days are assigned by passing the <code>WorkDays</code> collection for each doctor to show their available dates. On each of their available dates, their daily available
        time range is also depicted by mentioning the <code>StartHour</code> and <code>EndHour</code> for each doctor. These values needs to be provided along with the resource
        <code>DataSource</code> by mapping the appropriate fields namely <code>WorkDaysField</code>,<code>StartHourField</code>, and <code>EndHourField</code>.
    </p>
</ActionDescription>

<div class="control-section">
    <div class="content-wrapper">
        <SfSchedule TValue="ScheduleData.DoctorData" Width="100%" Height="650px" @bind-SelectedDate="@CurrentDate" AllowDragAndDrop="false" AllowResizing="false">
            <ScheduleViews>
                <ScheduleView Option="View.WorkWeek"></ScheduleView>
                <ScheduleView MaxEventsPerRow="2" Option="View.Month"></ScheduleView>
            </ScheduleViews>
            <ScheduleGroup Resources="@GroupData"></ScheduleGroup>
            <ScheduleResources>
                <ScheduleResource TItem="DoctorData" TValue="int" DataSource="@ResourceData" Field="DoctorId" Title="Doctor Name" Name="Doctors" TextField="Text" IdField="Id" ColorField="Color" WorkDaysField="WorkDays" StartHourField="StartHour" EndHourField="EndHour"></ScheduleResource>
            </ScheduleResources>
            <ScheduleEventSettings DataSource="@DataSource">
                <ScheduleField>
                    <FieldSubject Title="Service Type" Name="Subject"></FieldSubject>
                    <FieldLocation Title="Patient Name" Name="Location"></FieldLocation>
                    <FieldDescription Title="Summary" Name="Description"></FieldDescription>
                    <FieldStartTime Title="From" Name="StartTime"></FieldStartTime>
                    <FieldEndTime Title="To" Name="EndTime"></FieldEndTime>
                </ScheduleField>
            </ScheduleEventSettings>
        </SfSchedule>
    </div>
</div>
@code{
    private DateTime CurrentDate = new DateTime(2020, 3, 1);
    public List<ScheduleData.DoctorData> DataSource = new ScheduleData().GetDoctorData();
    public string[] GroupData = new string[] { "Doctors" };
    private List<DoctorData> ResourceData { get; set; } = new List<DoctorData> {
        new DoctorData { Text = "Will Smith", Id = 1, Color = "#ea7a57", WorkDays = new int[] { 1, 2, 4, 5 }, StartHour = "08:00", EndHour = "15:00" },
        new DoctorData { Text = "Alice", Id = 2, Color = "rgb(53, 124, 210)", WorkDays = new int[] { 1, 3, 5 }, StartHour = "08:00", EndHour = "17:00" },
        new DoctorData { Text = "Robson", Id = 3, Color = "#7fa900", StartHour = "08:00", EndHour = "16:00" }
    };
    public class DoctorData
    {
        public string Text { get; set; }
        public int Id { get; set; }
        public int[] WorkDays { get; set; }
        public string Color { get; set; }
        public string StartHour { get; set; }
        public string EndHour { get; set; }
    }
}
